package eu.webhib.extgui.data.service.intf;

import eu.webhib.extgui.data.intf.GuiBaseEntity;
import eu.webhib.frmwrk.service.intf.BaseService;

/**
 * Interface of a persistent entity service responsible for retrieving entities and managing the
 * persistent state for entities of type T
 * @param T type of the entity managed
 */
public interface GuiBaseService<T extends GuiBaseEntity> extends BaseService<T> {

   /**
    * Create a new entity with default attributes
    * @return new transient entity, not saved so far
    */
   @Override
   T createNew();

   /**
    * Save a new entity
    * @param newEntity the new entity to be added to the data store
    */
   @Override
   void save(T newEntity);

   /**
    * Update an entity from the object copy provided
    * @param entityToChange entity to be updated
    * @param changedEntity  a copy of the item holding the new attribute values
    *                       (including parent and other relationships)
    */
   @Override
   void updateFromCopy(T entityToChange, T changedEntity);

   /**
    * Delete the entity
    * @param entityToDelete the entity to be deleted
    */
   @Override
   void delete(T entityToDelete);
}
